home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 12
/
CU Amiga Magazine's Super CD-ROM 12 (1997)(EMAP Images)(GB)[!][issue 1997-07].iso
/
CUCD
/
Games
/
DestructivePoker
/
sources
/
sources.lha
/
double.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1997-02-20
|
5KB
|
189 lines
/*
double.cpp
V1.00 - 241196 Kimmo Teräväinen
----- ------ ----------------
Look double.h
*/
#include "double.h"
#ifdef _Windows
DEFINE_RESPONSE_TABLE1(TDoubleDialog,TDialog)
EV_BN_CLICKED(BUTTON_SMALL ,ButtonSmall),
EV_BN_CLICKED(BUTTON_BIG ,ButtonBig),
EV_BN_CLICKED(IDCANCEL ,ButtonOK),
EV_BN_CLICKED(IDOK ,ButtonOK),
END_RESPONSE_TABLE;
void TDoubleDialog::SetupWindow()
{
TDialog::SetupWindow();
CreateCard();
}
#else
#include <inline++/exec.h>
#include <stdio.h>
#include "requester.h"
#include "pokergadgets.h"
extern TextFont *TEXTFONT;
extern UBYTE pens[];
extern UBYTE gfxpens[256];
const cButton cDoubleGadgets::DoubleButtons[] = {
cButton(GADGET_OK , 50,149,100,14,"Don´t Double"),
cButton(GADGET_SMALL , 40,130, 50,14,"_Small"),
cButton(GADGET_BIG ,110,130, 50,14,"_Big"),
cButton(0,0,0,0,0,NULL)
};
void TDoubleDialog::Execute()
{
Window *Wnd=NULL;
int BTop = parent->WScreen->WBorTop + (parent->WScreen->Font->ta_YSize + 1);
{
struct TagItem window_tags[] = {
{ WA_Title, (long unsigned)"Double" },
{ WA_DragBar , TRUE},
{ WA_DepthGadget , TRUE},
{ WA_CloseGadget, TRUE },
{ WA_Left, 200+parent->LeftEdge }, { WA_Top, 40+parent->TopEdge },
{ WA_Width, 200 }, { WA_Height, 170+BTop },
{ WA_CustomScreen, (ULONG)parent->WScreen },
{ WA_Activate, TRUE},
{ WA_IDCMP, IDCMP_VANILLAKEY |
IDCMP_MOUSEBUTTONS |
IDCMP_GADGETUP |
IDCMP_REFRESHWINDOW |
IDCMP_CLOSEWINDOW },
{ TAG_DONE, NULL}
};
Wnd=OpenWindowTagList(NULL,window_tags);
}
if(Wnd)
{
SetFont(Wnd->RPort,TEXTFONT);
SetABPenDrMd(Wnd->RPort,gfxpens[0],gfxpens[0],JAM1);
RectFill(Wnd->RPort,Wnd->BorderLeft,Wnd->BorderTop,
Wnd->Width-Wnd->BorderRight,
Wnd->Height-Wnd->BorderBottom);
int RT,terminated=FALSE;
cDoubleGadgets doublegads(Wnd,game,win);
Move(Wnd->RPort,
(Wnd->Width-TextLength(Wnd->RPort,(UBYTE*)"Small or Big Card?",18))/2,
20+Wnd->BorderTop);
SetAPen(Wnd->RPort,pens[1]); SetDrMd(Wnd->RPort,JAM1); // Text
Text(Wnd->RPort,(UBYTE*)"Small or Big Card?",18); //
RefreshWindowFrame(Wnd);
while(!terminated) {
Message *msg;
WaitPort(Wnd->UserPort);
while(msg=GetMsg(Wnd->UserPort)) {
if((RT=doublegads.IDCMP((const IntuiMessage *)msg))==IDCMP_NOT_DONE)
switch(((IntuiMessage *)msg)->Class) {
case IDCMP_CLOSEWINDOW: terminated=TRUE; break;
}
if(RT==IDCMP_TERMINATED) terminated=TRUE;
if(RT!=IDCMP_REPLYED) ReplyMsg(msg);
}
}
CloseWindow(Wnd);
}
}
int cDoubleGadgets::GadgetSmall()
{
if(!card) return IDCMP_TERMINATED;
card->Turn_CoverUp();
if(card->Num()<6 || card->Suit()==JOKER) {
char buffer[40];
win+=win;
sprintf(buffer,"Win Pot Doubled! Pot=%ld",(ULONG)win);
cRequester(wnd,"Double Small",buffer).Execute();
CreateCard();
return IDCMP_DONE;
}
cRequester(wnd,"Double Small","Win Pot lost!").Execute();
return IDCMP_TERMINATED;
}
int cDoubleGadgets::GadgetBig()
{
if(!card) return IDCMP_TERMINATED;
card->Turn_CoverUp();
if(card->Num()>6 || card->Suit()==JOKER) {
char buffer[40];
win+=win;
sprintf(buffer,"Win Pot Doubled! Pot=%ld",(ULONG)win);
cRequester(wnd,"Double Big",buffer).Execute();
CreateCard();
return IDCMP_DONE;
}
cRequester(wnd,"Double Big","Win Pot lost!").Execute();
return IDCMP_TERMINATED;
}
int cDoubleGadgets::IDCMP(const IntuiMessage *msg)
{
switch(msg->Class) {
case IDCMP_REFRESHWINDOW:
GT_BeginRefresh(wnd);
GT_EndRefresh(wnd, TRUE);
return IDCMP_DONE;
case IDCMP_VANILLAKEY:
switch(msg->Code) {
case 10:
case 13: game->Money_Add(win);
case 27: return IDCMP_TERMINATED;
case 's':
case 'S': return GadgetSmall();
case 'b':
case 'B': return GadgetBig();
}
break;
case IDCMP_GADGETUP:
{
Gadget *gad = (struct Gadget *)msg->IAddress;
switch(gad->GadgetID) {
case GADGET_SMALL: return GadgetSmall();
case GADGET_BIG: return GadgetBig();
case GADGET_OK: game->Money_Add(win);
return IDCMP_TERMINATED;
}
return IDCMP_DONE;
}
case IDCMP_CLOSEWINDOW:
game->Money_Add(win);
return IDCMP_TERMINATED;
}
return IDCMP_NOT_DONE;
}
#endif